#include <iostream>
#include <unistd.h>
#include <stdlib.h>
using namespace std;


int main()
{
    pid_t id = fork();
    if(id == 0)
    {
        while(1)
        {
            cout << "这是子进程：pid：" << getpid() << ", ppid：" << getppid() << endl;
            sleep(1);
        }
    }
    if(id > 0)
    {
        int count = 5;
        while(count)
        {
            cout << "这是父进程：pid：" << getpid() << ", ppid：" << getppid() << ", count：" << count << endl;
            count--;
            sleep(1);
        }
        exit(0);
    }


    //cout << "Enter: " << endl;
    //int a;
    //cin >> a;
    //cout << a << endl;


    //while(1)
    //    {
    //        cout << "Hello Linux" << endl;
    //        sleep(1);
    //    }

    return 0;
}

